﻿using System;
using System.Collections.Generic;
using System.Text;
using ShootSearch.FileSystem;
using log4net;

namespace ShootSearch.Parsers
{
    public class PlainParser : IParser
    {
        public PlainParser()
        {
            ContentType = new List<string>();
            ContentType.Add("text/plain");
        }

        #region IFilter Members

        public List<string> ContentType { get; protected set; }

        public bool Parse( IFileObject input, out IFileObject output)
        {
            output =null;
            if(input==null) return false;

            string text = input.Encoding.GetString(input.Content);
            FileObjectText doc = new FileObjectText(input.Url, input.DateTime);

            doc.Add("Title", input.Url);
            doc.Add("Content", text);
            output = doc;
            return true;
        }

        #endregion

        #region IConfigable Members

        public ShootSearch.Core.SpiderManConfig Config { get; set; }
        public ILog Logger { get; set; }

        #endregion
    }
}
